<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<%@ include file="/pages/login/common.jsp" %>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta content="B2B电商平台" name="description"/>
<meta content="B2B电商平台" name="keyword"/>

<title>B2B电商平台.店铺</title>
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/style.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/btn.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/themes.css" />
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/demo.css">
<link rel="stylesheet" href="<%=path%>/include/JQuery zTree v3.4/css/zTreeStyle/zTreeStyle.css">
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/register_icss.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/sweetalert/sweetalert.css" />
<link rel="stylesheet" type="text/css" href="<%=path %>/include/css/mmt_trading.css" />
<link rel="stylesheet" href="<%=path %>/include/JQuery ui/select2/css/select2.min.css" type="text/css"></link>

<script type="text/javascript" src="<%=path %>/include/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.common.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/icss.shop.apply.js"></script>
<script type="text/javascript" src="<%=path %>/include/js/cookies.js"></script>

<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.core-3.4.js"></script>
<script type="text/javascript" src="<%=path%>/include/JQuery zTree v3.4/js/jquery.ztree.excheck-3.4.js"></script>

<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert.min.js"></script>
<script type="text/javascript" src="<%=path %>/include/sweetalert/sweetalert-dev.js"></script>
<script type="text/javascript" src="<%=path %>/include/JQuery ui/select2/js/select2.min.js"></script>

	<link rel="stylesheet" href="<%=path%>/include/layui/css/layui.css"  media="all">
    <script type="text/javascript" src="<%=path %>/include/layui/lay/dest/layui.all.js" charset="utf-8"></script>
    
    <script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.0&key=5434d60a0e0988dba6e607cad99df7c8"></script>
    <script src="//webapi.amap.com/ui/1.0/main.js"></script>
    
<style type="text/css">
body{}
table{border-collapse: collapse;}
tr{ 
    display:block; /*将tr设置为块体元素*/ 
    margin:10px;  /*设置tr间距为2px*/ 
}
td{height:30px; line-height:30px;}
.td1{
	width:120px;
	font-size:14px;
	text-align:right;
	vertical-align: middle;
}
.td_1{
	width: 180px;white-space: nowrap;
}
#btnDiv a:hover{
   color:white;
}
button{
    width:44px;
    height:24px;
    line-height:24px;   
    background-color: transparent;
    background-repeat: no-repeat;
    background-position: 0 -203px;
    border:0;
    cursor:pointer;
    font: 12px/1.5 arial,tahoma,\5b8b\4f53;
    margin: 0 0 0 5px;
    outline:none;
    background-image: url('<%=path%>/include/css/img/xs_bgx.png');   
}
.input1{
	width:200px;
	height:30px;
	line-height:30px;
	vertical-align:middle;
	float:left;
}
.input2{
	width:100px;
	height:30px;
	line-height:30px;
	vertical-align:middle;
}
.select1{
	width: 196px;
    height: 30px;
}
.select2{
    height: 30px;
}
.acss:hover{
	background: #fff;
}
.ps tr{
	margin: 2px 0px;
}
.amap-logo {
	display: none !important;
} 
.amap-copyright {
    bottom:-100px;
    display: none;
}  
.promptBox{display:inline-block;height:30px;padding-left:5px;width:160px;white-space:nowrap; z-index:50; position:relative;}
.tips-errow{background-position:-296px -22px;color:#f52c2c;}
.tips-ok{background-position:-296px 14px;color:#666;}
.tipsCur{background-position:-296px -55px;color:#666;}
.approveDiv{float:right;color:blue;margin-right:10px;}
#tip {
    background-color: #ddf;
    color: #333;
    border: 1px solid silver;
    box-shadow: 3px 4px 3px 0px silver;
    position: absolute;
    margin-top: -240px;
    margin-left: 100px;
    border-radius: 5px;
    overflow: hidden;
    line-height: 20px;
}
#tip input[type="text"] {
    height: 25px;
    border: 0;
    padding-left: 5px;
    width: 280px;
    border-radius: 3px;
    outline: none;
}
.amap-sug-result{ width: 280px;}
</style>
<script type="text/javascript">
	var approveStatus = '${shopInfo.REGISTER_STATUS}';
//	var approveStatus = '1';
	$(function(){
		/*if(approveStatus == ''){
			$("#approveDiv").hide();
		}else if(approveStatus == 0){
			//$("#approveDiv").html("审核状态：待审核");
			//$("#btnDiv").hide();
			//$('input,select,textarea',$('form[name="fm"]')).prop('readonly',true); 
		}else if(approveStatus == 1){
			//$("#approveDiv").html("审核状态：审核通过");
			//$("#btnDiv").hide();
			//$('input,select,textarea',$('form[name="fm"]')).prop('readonly',true); 
		}else if(approveStatus == 2){
			//$("#approveDiv").html("审核状态：审核不通过");
		}*/
		_changeType();
		_setPayType();
	});

	function saveShop(val){
		if(val!='2') $("#status").val("");
		var checked = $("#statement").is(':checked');
		if(!checked){
			parent.swal("请勾选徽映优选供应商入驻协议");
			return;
		}
		var deliveryStr = "0";
		$("input[name^='deliveryArea']").each(function(){
				deliveryStr += ","+this.id;
		});
		var re = new RegExp("deliveryArea","g");
		deliveryStr = deliveryStr.replace(re,"");
		deliveryStr = deliveryStr.substring(2);
		$("#deliveryStr").val(deliveryStr);
		_getPayType();
		_checkDeliveryNum();

		var ifHurryUp = $("input[name='ifHurryUp']:checked").val();
		if(ifHurryUp=="1"){
			var val = $("#jsdMinute").val();
			var time = $("#SET_TYPE_LIMIT").val();
			$("#jsdMinute1").val(val);
			if(val != null && val != ''){
				var t = parseInt(time);
				var v = parseInt(val);
				if(v>t){
					parent.swal("", "急速达配送时间应不大于"+time+"分钟", "error");
					$("#jsdMinute").val("720");
					$("#jsdMinute1").val("720");
					return;
				}
			}else{
				parent.swal("", "急速达配送时间不能为空", "error");
				return;
			}
		}
		
		var flag1 = $("#flag1").val();
		if(flag1=="0"){
			parent.swal("", "配送范围数据不能小于上一级数据", "error");
			return;
		}
		var payOnline = $("#payOnline").val();
		if(payOnline=="1"||payOnline=="2"){
			var payType = $("#payType").val();
			if(payType==null||payType==""){
				parent.swal("", "在线支付必须要选储蓄卡、信用卡或微信等支付方式", "error");
				return;
			}
		}
		if(_checkAllReady()){
			$.ajax({
	              cache: true,
	              type: "POST",
	              url:'<%=path%>/storeApplyAction/saveTwo.do',
	              data:$('#fm').serialize(),
	              dataType:"json",
	              error: function(request) {
	                 parent.swal("", "提交失败!", "error");
	              },
	              success: function(data) {
	            	  var msg = data.result;
		                if(msg=="保存成功"){
							//parent.swal("", msg, "success");
							var showFlag = $("#showFlag").val();
							if(showFlag=="1")
								window.location.href = '<%=path %>/storeApplyAction/toStoreInfo.do?shopId='+data.shopId;
							else
								window.location.href = '<%=path %>/storeApplyAction/toStoreApplyThrPage.do?shopId='+data.shopId;
						}else {
							parent.swal("", msg, "error");
						}
		      	 }
	         });
		}
	}

	function _statementInfo(){
		$(window.parent.document).find("#rightFrame").height(600);
    	var url = "<%=path%>/pages/storeApply/statement.jsp";
    	parent.layer.open({
  			title: '',
  			type: 2, 
  			area: ['800px', '500px'],
  			content: [url,'no'], //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: [url, 'no']
  			end:function(){
  				_reHeight();
  				$("#statement").attr("checked",'true');
  			}
		});
    }

	function _goBack(){
		window.location.href = '<%=path %>/storeApplyAction/getStorePage.do?shopStatus=0&shopId='+$("#shopId").val();
	}

	function _changeHurryUp(){
		var ifHurryUp = $("input[name='ifHurryUp']:checked").val();
		if(ifHurryUp=="1"){
			$("#ifHurryUpTr").show();
			$("#jsdTr").show();
		}else{
			$("#ifHurryUpTr").hide();
			$("#jsdTr").hide();
		}
	}

	function _changeType(){
		var payOnline = 0;
		$("input[name='payOnline1']:checked").each(function(){ 
			payOnline += parseInt($(this).val()); 
		});
		payOnline = payOnline == 0 ? payOnline : --payOnline;
		$("#payOnline").val(payOnline);
		if(payOnline==0){
			$("#payTypeTr").hide();
		}else{
			$("#payTypeTr").show();
		}
	}

	function _addDelivery(){
		var len = $("#deliveryId tr").length;
		var html = "<tr>";
		html += "		<td class='td_1 rightTd'>范围：<input onblur=\"_checkNum(this.value,'deliveryArea',"+(len+1)+")\" class='input2 valSize' id='deliveryArea"+(len+1)+"' name='deliveryArea"+(len+1)+"' value=''/>&nbsp;米</td>";
		html += "		<td class='td_1 rightTd'>配送费：<input onblur=\"_checkNum(this.value,'deliveryFee',"+(len+1)+")\" class='input2' id='deliveryFee"+(len+1)+"' name='deliveryFee"+(len+1)+"' value=''/>&nbsp;元</td>";
		html += "		<td class='td_1 rightTd'>&nbsp;&nbsp;&nbsp;&nbsp;配送时间：<input class='input2' id='deliveryHour"+(len+1)+"' name='deliveryHour"+(len+1)+"' value=''/>&nbsp;小时</td>";
		html += "		<td>&nbsp;&nbsp;<a onclick=\"$(this).parent().parent().remove();\" class='btn btn-primary' style='text-decoration:none;'>删除</a></td>";
		html += "	</tr>";
		$("#deliveryId").append(html);
		_reHeight();
	}

	function _setPayType(){
		var type = '${shopInfo.PAY_TYPE}';
		$("[name='payType1']").each(function(){ 
			var val = $(this).val();
			if(type.indexOf(val)>=0) $(this).attr("checked",'true');
		});
	}

	function _getPayType(){
		var str = "0";
		$("input[name='payType1']:checked").each(function(){   
			str += "," + $(this).val();   
		});
		str = str.substring(2);
		$("#payType").val(str);
	}

	function _checkNum(val,name,num){
		var flag = false;
		var id = name+num;
		var idstr = name == "deliveryArea" ? "hurryUpAre1" : "hurryUpFe1";
		var v1 = parseInt($("#"+idstr).val());
		v1 = isNaN(v1) ? 0 : v1;
		if(parseInt(val) > v1){
			$("input[name^='"+name+"']").each(function(){
				if(id>this.id&&parseInt(val)<=parseInt(this.value)) flag = true;
			});
		} else  flag = true;
		if(flag) {
			parent.swal("", "数据应大于上级数据", "error");
			$("#flag1").val("0");
		}else{
			$("#flag1").val("1");
		}
	}

	function _checkDeliveryNum(){
		var flag = false;
		var val = "0";
		var id = "d";
		$("input[name^='deliveryArea']").each(function(){
			if(id<this.id&&parseInt(val)>=parseInt(this.value)) flag = true;
			val = this.value;
			id = this.id;
		});
		val = "0";
		id = "d";
		$("input[name^='deliveryFee']").each(function(){
			if(id<this.id&&parseInt(val)>=parseInt(this.value)) flag = true;
			val = this.value;
			id = this.id;
		});
		if(flag) {
			//parent.swal("", "数据要大于上级数据", "error");
			$("#flag1").val("0");
		}else{
			$("#flag1").val("1");
		}
	}

	function _checkHurryUp(id){
		var val = $("#hurryUp"+id).val();
		var flag = false;
		$("input[name^='delivery"+id+"']").each(function(){
			if(parseInt(val)>=parseInt(this.value)) flag = true;
		});
		if(flag) {
			parent.swal("", "急速达数据要应小于配送范围数据", "error");
			$("#flag1").val("0");
		}else{
			$("#flag1").val("1");
		}
	}

	function _jsdMinuteSet(val){
		var time = $("#SET_TYPE_LIMIT").val();
		$("#jsdMinute1").val(val);
		if(time != null && time != ''){
			var t = parseInt(time);
			var v = parseInt(val);
			if(v>t){
				parent.swal("", "急速达配送时间应不大于"+time+"分钟", "error");
				$("#jsdMinute").val("720");
				$("#jsdMinute1").val("720");
				return;
			}
		}
	}
	
</script>
</head>
<body style="font-family: '微软雅黑'">
	<div id="contentDiv" style="padding:5px; width:99%;margin: 0px;">
		<div style="width:100%;height:30px;border-bottom:1px solid #ADADAD;">
			<div class="toptil">开店申请-经营信息</div>
	 		<div id="approveDiv" class="approveDiv">
	 		</div>
		</div>
		<form id="fm" name="fm" class="form-horizontal form-validate" method="post" action="" novalidate="novalidate">
			<input type="hidden" id="shopId" name="shopId" value="${shopInfo.SHOP_ID }">
			<input type="hidden" id="curPath" name="curPath" value="<%=path %>">
			<input type="hidden" id="showFlag" name="showFlag" value="${showFlag }">
			<input type="hidden" id="flag1" name="flag1" value="">
			<input type="hidden" id="deliveryStr" name="deliveryStr" value="">
			<input type="hidden" id="shopStatus" name="shopStatus" value="${shopInfo.SHOP_STATUS }">
			<input type="hidden" id="status" name="status" value="${shopInfo.STATUS }">
			<div style="width:100%;margin-top:20px;margin-left:10px;">
				<table style="width:100%;">
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">经营区域：</td>
						<td class="rightTd" nowrap>
							<textarea id="citySel" name="citySel" readonly style="width: 400px; height: 80px; resize: none;" onclick="showMenu();">${areaName}</textarea>
							<input type="hidden" id="shopArea" name="shopArea" value="${areaCode}">
							<div id="menuContent" class="menuContent" style="display:none; position: absolute;z-index:99;">
								<ul id="treeDemo" class="ztree" style="margin-top:0; width:400px;height:230px;"></ul>
							</div>
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请选择经营区域</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请选择经营区域</div>
		                   	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">营业执照：</td>
						<td class="rightTd" nowrap>
							<div id="businessLicenseDiv" style="float:left;text-align:center;">
								<div id="imgDiv5" style="margin-bottom:10px;">
									<img src="${shopInfo.BUSINESS_LICENSE }" onerror="javascript:this.src='<%=path%>/download/error/nopicture.jpg'"
										id="imgView5" style="height: 75px; width: 100px;">
								</div>
								<div id="file1" class="site-demo-upbar" style="">
								    <input type="file" name="file" class="layui-upload-file" id="img5">
								</div>
								<input id="businessLicense" name="businessLicense" type="hidden" value="${shopInfo.BUSINESS_LICENSE }">
							</div>
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请上传营业执照</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请上传营业执照</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">经营范围：</td>
						<td class="rightTd" nowrap>
							<textarea id="businessScope" name="businessScope" style="width: 400px; height: 80px; resize: none;">${shopInfo.BUSINESS_SCOPE }</textarea>
							<div class="promptBox">
		                   		<div class='tips-errow' style="display:none;">请输入经营范围</div>
		                   		<div class='tips-ok' style="display:none;"></div>
		                   		<div class='tipsCur' style="display:none;">请输入经营范围</div>
		                   	</div>	
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">店铺坐标：</td>
						<td class="rightTd" nowrap>
							<table>
								<tr style="margin-top: 0px;margin-left: 0px;" onclick="$('#container').show();$('#tip').show();$('#closeBtn').show();_reHeight();">
									<td class="td_1">经度：<input readonly="readonly" class="input2" id="pointX" name="pointX" value="${shopInfo.LONGITUDE }"/>&nbsp;</td>
									<td class="td_1" nowrap>纬度：<input readonly="readonly" class="input2" id="pointY" name="pointY" value="${shopInfo.LATITUDE }"/>&nbsp;</td>
								</tr>
							</table>
							<div id="container" tabindex="0" style="width: 400px;height: 250px;display: none;"></div>
							<div id="tip" style="display: none;">
							    <input type="text" id="keyword" name="keyword" value="请输入关键字：(选定后搜索)" onfocus='this.value=""'/>
							</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">是否允许发快递：</td>
						<td class="rightTd" nowrap>
							<input type="radio" name="isExpressDelivery" value="1" <c:if test="${shopInfo.IS_EXPRESS_DELIVERY eq '1' }">checked</c:if> />是&nbsp;
							<input type="radio" name="isExpressDelivery" value="0" <c:if test="${shopInfo.IS_EXPRESS_DELIVERY eq null or shopInfo.IS_EXPRESS_DELIVERY eq '0' }">checked</c:if> />否&nbsp;
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">是否急速达：</td>
						<td class="rightTd" nowrap onclick="_changeHurryUp()">
							<input type="radio" name="ifHurryUp" value="1" <c:if test="${shopInfo.IF_HURRY_UP eq '1' }">checked</c:if> />是&nbsp;
							<input type="radio" name="ifHurryUp" value="0" <c:if test="${shopInfo.IF_HURRY_UP eq null or shopInfo.IF_HURRY_UP eq '0' }">checked</c:if> />否&nbsp;
						</td>
					</tr>
					<tr id="ifHurryUpTr" <c:if test="${shopInfo.IF_HURRY_UP eq null or shopInfo.IF_HURRY_UP eq '0' }">style="display: none;"</c:if>>
						<td class="td1" nowrap style="vertical-align:top;"> </td>
						<td class="" nowrap>
							<table>
								<tr style="margin: 0px;">
									<td class="td_1">范围：<input onblur="_checkHurryUp('Area')" onkeyup="$('#hurryUpAre1').val(this.value)" class="input2" id="hurryUpArea" name="hurryUpArea" value="${shopInfo.HURRY_UP_AREA }"/>&nbsp;米</td>
									<td class="td_1">配送费：<input onblur="_checkHurryUp('Fee')" onkeyup="$('#hurryUpFe1').val(this.value)" class="input2" id="hurryUpFee" name="hurryUpFee" value="${shopInfo.HURRY_UP_FEE }"/>&nbsp;元</td>
									<td class="td_1">&nbsp;&nbsp;&nbsp;&nbsp;配送时间：<input onkeyup="_jsdMinuteSet(this.value)" class="input2" id="jsdMinute" name="jsdMinute" value="${shopInfo.JSD_MINUTE }">&nbsp;分钟</td>
								</tr>
							</table>
							<input type="hidden" id="SET_TYPE_LIMIT" name="SET_TYPE_LIMIT" value="${shopInfo.SET_TYPE_LIMIT }"/>
							<div style="font-size: 12px;color: #777;margin-top: 5px;display: none;">急速达：需在<span style="color: red;font-size: 14px;font-weight: bold;display: none;">15分钟内</span>送达，并客户签收</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">配送范围：</td>
						<td nowrap>
							<table id="deliveryId" class="ps">
								<tr id="jsdTr" <c:if test="${shopInfo.IF_HURRY_UP eq '0' or shopInfo.IF_HURRY_UP eq null}">style="display: none;"</c:if>>
									<td class="td_1">范围：<input disabled="disabled" class="input2" id="hurryUpAre1" name="hurryUpAre1" value="${shopInfo.HURRY_UP_AREA }"/>&nbsp;米</td>
									<td class="td_1">配送费：<input disabled="disabled" class="input2" id="hurryUpFe1" name="hurryUpFe1" value="${shopInfo.HURRY_UP_FEE }"/>&nbsp;元</td>
									<td class="td_1">&nbsp;&nbsp;&nbsp;&nbsp;配送时间：<input disabled="disabled" class="input2" id="jsdMinute1" name="jsdMinute1" value="${shopInfo.JSD_MINUTE }">&nbsp;分钟</td>
								</tr>
								<c:forEach items="${deliveryFeeList }" var="item" varStatus="status">
									<tr>
										<td class="td_1 rightTd">范围：<input onblur="_checkNum(this.value,'deliveryArea',${status.count })" class="input2 valSize" id="deliveryArea${status.count }" name="deliveryArea${status.count }" value="${item.DELIVERY_AREA }"/>&nbsp;米</td>
										<td class="td_1 rightTd">配送费：<input onblur="_checkNum(this.value,'deliveryFee',${status.count })" class="input2" id="deliveryFee${status.count }" name="deliveryFee${status.count }" value="${item.DELIVERY_FEE }"/>&nbsp;元</td>
										<td class="td_1 rightTd">&nbsp;&nbsp;&nbsp;&nbsp;配送时间：<input class="input2" id="deliveryHour${status.count }" name="deliveryHour${status.count }" value="${item.DELIVERY_HOUR }"/>&nbsp;小时</td>
										<td>&nbsp;&nbsp;<a onclick="$(this).parent().parent().remove();" class="btn btn-primary" style="text-decoration:none;">删除</a></td>
									</tr>
								</c:forEach>
							</table>
							<div><a onclick="_addDelivery();" class="btn btn-primary" style="text-decoration:none;">添加</a></div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap style="vertical-align:top;">支付方式：</td>
						<td class="rightTd" nowrap onclick="_changeType()">
							<input type="hidden" name="payOnline" id="payOnline" value="${shopInfo.PAY_ONLINE }"/>
							<input type="checkbox" name="payOnline1" value="2"  <c:if test="${shopInfo.PAY_ONLINE eq '1' or shopInfo.PAY_ONLINE eq '2'}">checked</c:if> />在线支付&nbsp;
							<input type="checkbox" name="payOnline1" value="1"  <c:if test="${shopInfo.PAY_ONLINE eq '0' or shopInfo.PAY_ONLINE eq '2'}">checked</c:if> />现金支付&nbsp;
						</td>
					</tr>
					<tr id="payTypeTr" <c:if test="${shopInfo.PAY_ONLINE eq '0'}"> style="display: none;"</c:if>>
						<td class="td1" nowrap style="vertical-align:top;"> </td>
						<td class="" nowrap>
							<input type="hidden" name="payType" id="payType" value="${shopInfo.PAY_TYPE}"/>
							<input type="checkbox" name="payType1" value="01"/>储蓄卡&nbsp;
							<input type="checkbox" name="payType1" value="02"/>信用卡&nbsp;
							<input type="checkbox" name="payType1" value="03"/>微信&nbsp;
							<!-- <input type="checkbox" name="payType1" value="04"/>支付宝&nbsp; -->
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap>起送金额：</td>
						<td class="rightTd" nowrap>
							<input class="input1" id="startMoney" name="startMoney" value="${shopInfo.START_MONEY }">
							<div class="promptBox">
	                       		<div class='tips-errow' style="display:none;">起送金额不符合</div>
	                       		<div class='tips-ok' style="display:none;"></div>
	                       		<div class='tipsCur' style="display:none;">请输入起送金额</div>
	                       	</div>
						</td>
					</tr>
					<tr>
						<td class="td1" nowrap><input type="checkbox" checked="checked" id="statement" name="statement" /> </td>
						<td class="rightTd" nowrap style="color: #999">
							已阅读并同意<a class="acss" onclick="_statementInfo()" style="color: #4b8cf7;">《徽映优选供应商入驻协议》</a>
						</td>
					</tr>
					<tr>
						<td class="td1">&nbsp;</td>
						<td style="">
							<c:if test="${showFlag ne '1'}">
								<div id="btnDiv" style="float: left;">
									<a onclick="_goBack();" class="btn btn-primary" style="text-decoration:none;">上一步</a>
								</div>
								<div id="btnDiv" style="float: left;margin-left: 15px;">
									<a onclick="saveShop('0');" class="btn btn-primary" style="text-decoration:none;">下一步</a>
								</div>
							</c:if>
							<c:if test="${showFlag eq '1'}">
								<div id="btnDiv" style="float: left;">
									<a onclick="saveShop('1');" class="btn btn-primary" style="text-decoration:none;">保存</a>
								</div>
								<c:if test="${shopInfo.STATUS eq '2'}">
									<div id="btnDiv" style="float: left;margin-left: 15px;">
										<a onclick="saveShop('2');" class="btn btn-primary" style="text-decoration:none;">提交</a>
									</div>
								</c:if>
							</c:if>
						</td>
					</tr>
				</table>
			</div>
		</form>
	</div>
</body>
<script type="text/javascript">
AMapUI.loadUI(['misc/PositionPicker'], function(PositionPicker) {
	var pointX = '${shopInfo.LONGITUDE }';
	var pointY = '${shopInfo.LATITUDE }';
	var map ;
	if(pointX!=""&&pointY!=""){
	    map = new AMap.Map('container',{
	    	resizeEnable: true,
	        center: [pointX, pointY],   
	        zoom:16
	    });
	}else{
	    map = new AMap.Map('container',{
	    	resizeEnable: true,
	        zoom:16
	    });
	}

	 AMap.plugin(['AMap.Autocomplete','AMap.PlaceSearch'],function(){
	        var autoOptions = {
	          city: "合肥", //城市，默认全国
	          input: "keyword"//使用联想输入的input的id
	        };
	        autocomplete= new AMap.Autocomplete(autoOptions);
	        var placeSearch = new AMap.PlaceSearch({
	              city:'合肥',
	              map:map
	        })
	        AMap.event.addListener(autocomplete, "select", function(e){
	           //TODO 针对选中的poi实现自己的功能
	           placeSearch.setCity(e.poi.adcode);
	           placeSearch.search(e.poi.name)
	        });
	      });
    
    var positionPicker = new PositionPicker({
        mode:'dragMap',//设定为拖拽地图模式，可选'dragMap'、'dragMarker'，默认为'dragMap'
        map:map//依赖地图对象
    });
    positionPicker.on('success', function(positionResult) {
        $("#pointX").val(positionResult.position.lng);
        $("#pointY").val(positionResult.position.lat);
        /*document.getElementById('lnglat').innerHTML = positionResult.position.position;
        document.getElementById('address').innerHTML = positionResult.address;
        document.getElementById('nearestJunction').innerHTML = positionResult.nearestJunction;
        document.getElementById('nearestRoad').innerHTML = positionResult.nearestRoad;
        document.getElementById('nearestPOI').innerHTML = positionResult.nearestPOI;*/
    });
    positionPicker.on('fail', function(positionResult) {
        // 海上或海外无法获得地址信息
    });
    //TODO:事件绑定、结果处理等
    positionPicker.start();

});
</script>
<script type="text/javascript">
layui.use('upload', function(){
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img1' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'正面照'
	    ,success: function(res){
			$("#idcardF").val(res.url);
			$("#imgView1").attr("src", res.url);
			if($.trim($("#idcardF").val()) != '' && $.trim($("#idcardB").val()) != ''){
				$("#idcardDiv").nextAll('div').find(".tips-errow").hide();
				$("#idcardDiv").nextAll('div').find(".tipsCur").hide();
				$("#idcardDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img2' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'反面照'
	    ,success: function(res){
			$("#idcardB").val(res.url);
			$("#imgView2").attr("src", res.url);
			$("#idcardB").parent().nextAll().find(".tips-ok").hide();
			$("#idcardB").parent().nextAll().find(".tips-errow").hide();
			$("#idcardB").parent().nextAll().find(".tipsCur").show();
			if($.trim($("#idcardF").val()) != '' && $.trim($("#idcardB").val()) != ''){
					$("#idcardDiv").nextAll('div').find(".tips-errow").hide();
				$("#idcardDiv").nextAll('div').find(".tipsCur").hide();
				$("#idcardDiv").nextAll('div').find(".tips-ok").show();
				}
	    }
	 });
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img3' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'店铺logo'
	    ,success: function(res){
		 	$("#shopLogo").val(res.url);
			$("#imgView3").attr("src", res.url); 
			if($.trim($("#shopLogo").val()) != ''){
				$("#shopLogoDiv").nextAll('div').find(".tips-errow").hide();
				$("#shopLogoDiv").nextAll('div').find(".tipsCur").hide();
				$("#shopLogoDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img4' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'宣传图片'
	    ,success: function(res){
	       	$("#shopPic").val(res.url);
			$("#imgView4").attr("src", res.url);
			if($.trim($("#shopPic").val()) != ''){
				$("#shopPicDiv").nextAll('div').find(".tips-errow").hide();
				$("#shopPicDiv").nextAll('div').find(".tipsCur").hide();
				$("#shopPicDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
	 layui.upload({
	  	url: '<%=path%>/upload/uploadPic'
	   	,elem: '#img5' //指定原始元素，默认直接查找class="layui-upload-file"
	    //,method: 'post' //上传接口的http类型
	    ,title:'上传'
	    ,success: function(res){
		 	$("#businessLicense").val(res.url);
			$("#imgView5").attr("src", res.url);
			if($.trim($("#businessLicense").val()) != ''){
				$("#businessLicenseDiv").nextAll('div').find(".tips-errow").hide();
				$("#businessLicenseDiv").nextAll('div').find(".tipsCur").hide();
				$("#businessLicenseDiv").nextAll('div').find(".tips-ok").show();
			}
	    }
	 });
});
</script>
<script type="text/javascript">
	var zTree = null;
	$(document).ready(function(){
		_reHeight();
		zTree = $.fn.zTree.init($("#treeDemo"), treeSetting);
		$("#bankCode").select2();
	});
	function _reHeight(){
		var main = $(window.parent.document).find("#rightFrame");
		var mainheight = $("#contentDiv").height()+120;
		main.height(mainheight);
	}
	
	/* 
	 * 下拉树的设置 
	 */  
	var treeSetting = {  
	    view: {  
	        dblClickExpand: false  
	    },  
		data: {  
			simpleData: {  
			    enable: true,
			    rootPId: 0
			}  
		},
		check: {  
			enable: true,
			autoCheckTrigger:true
		}, 
		async:{
			enable: true,//设置ztree是否开启异步加载模式
			showLine: true ,//设置是否显示连接线
			type: "post",//post方式请求数据
			url: getUrl,//数据请求url
			autoParam:["id","name"],//异步加载时需要自动提交父节点属性的参数
			otherParam:{"otherParam":"zTreeAsyncTest"},
			dataFilter: filter
		},
		callback: {
			beforeClick: beforeClick,
			onCheck: onCheck,
			onAsyncError : zTreeOnAsyncError,//加载失败
			onAsyncSuccess: zTreeOnAsyncSuccess//加载完成
		}
	}; 
	
	function getUrl(treeId, treeNode){
		var shopId = $("#shopId").val();
		var url = "<%=path %>/shopManage/getTree.do?shopId=" + shopId;
		return url;
	}
	
	function beforeClick(treeId, treeNode) {
		var zTree = $.fn.zTree.getZTreeObj("treeDemo");
		zTree.checkNode(treeNode, !treeNode.checked, null, true);
		return false;
	}
	
	/* 
	 * 点击事件 
	 */  
	function onCheck(e, treeId, treeNode) {  
		
		var cityObj = $("#citySel");
		var shopAreaObj = $("#shopArea");
	    var zTree = $.fn.zTree.getZTreeObj("treeDemo");
		var nodes = zTree.getCheckedNodes(true);
		var changeNodes = zTree.getChangeCheckedNodes();
		var v = '';
		var ids = '';
		for (var i=0, l=nodes.length; i<l; i++) {
			if(!nodes[i].isParent){
				v += nodes[i].aname + ",";
				ids += nodes[i].id + ",";
			}
		}
		if (v.length > 0 ) v = v.substring(0, v.length-1);
		if (ids.length > 0 ) ids = ids.substring(0, ids.length-1);
		cityObj.attr("value", v);
		shopAreaObj.attr("value", ids);
	}  
	//过滤函数  
    function filter(treeId, parentNode, childNodes) {  
        if (!childNodes)  
            return null;  
        for ( var i = 0, l = childNodes.length; i < l; i++) {  
            //childNodes[i].name = childNodes[i].name.replace(/\.n/g, '.');  
        }  
        return childNodes;  
    }  
    //加载完成
	var firstAsyncSuccessFlag = 0;
	function zTreeOnAsyncSuccess(event, treeId, msg) {
		if (firstAsyncSuccessFlag == 0) {
        	try {
				//调用默认展开第一个结点
			//	var nodes = zTree.getNodes();
			//	zTree.expandNode(nodes[0], true);
			//	for(var i = 0; i< nodes.length; i++){
			//		zTree.expandNode(nodes[i], true);
			//	}
			//	$("#treeDemo").click();
	            
	            //异步加载完成再折叠所有子节点
	            var nodes = zTree.getNodes();
				if (nodes.length>0) {
					var index = zTree.getNodeIndex(nodes[0]);
					for(var j=0; j<nodes.length; j++){
						var rootNode = nodes[j];
						zTree.expandNode(rootNode, false, true, null, true);
					}
				}
	            
	            firstAsyncSuccessFlag = 1;
        	} catch (err) {
	              
         	}
    	}
	}
	function hideMenu() {
		$("#menuContent").fadeOut("fast");
		$("body").unbind("mousedown", onBodyDown);
	}
	
	function onBodyDown(event) {
		if (!(event.target.id == "menuBtn" || event.target.id == "menuContent" || $(event.target).parents("#menuContent").length>0)) {
			hideMenu();
		}
	}
	
	function showMenu() {
		var cityObj = $("#citySel");
		var cityOffset = $("#citySel").offset();
		$("#menuContent").css({left:cityOffset.left + "px", top:cityOffset.top + cityObj.outerHeight() + "px"}).slideDown("fast");
		$("body").bind("mousedown", onBodyDown);
	}
	//加载失败提示  
    function zTreeOnAsyncError(event, treeId, treeNode, XMLHttpRequest, textStatus, errorThrown) {  
        parent.swal("", "经营区域加载失败，请稍后再试", "info");
    }; 
</script>
</html>
